import React from 'react';

import { View, StyleSheet, Text, TouchableHighlight } from 'react-native';
import theme from '../native-base-theme/variables';

export default ({ name, value, fontColor, choiceMethod }) => (
  <View style={styles.itemContainer}>
    <View style={styles.itemLeftContainer}>
      <Text style={[styles.fontStyle, { color: fontColor !== undefined ? fontColor : 'white' }]}>{name}</Text>
    </View>
    <View style={styles.itemRightContainer}>
      <Text style={[styles.fontStyle, { color: fontColor !== undefined ? fontColor : 'white' }]}>{value}</Text>
    </View>
    <View style={styles.itemChoiceContainer}>
      <TouchableHighlight
        activeOpacity={0.8}
        style={[styles.selectBtn, { borderColor: fontColor !== undefined ? fontColor : 'white' }]}
        onPress={() => choiceMethod()}
      >
        <Text style={[styles.fontStyle, { color: fontColor !== undefined ? fontColor : 'white' }]}>选择</Text>
      </TouchableHighlight>
    </View>
  </View>
);

const styles = StyleSheet.create({
  itemContainer: {
    padding: 8,
    flexDirection: 'row',
    flex: 1,
    alignItems: 'center',
  },
  itemLeftContainer: {
    flex: 2,
    marginRight: 5,
    justifyContent: 'center',
  },
  itemRightContainer: {
    flex: 3,
    flexWrap: 'wrap',
    justifyContent: 'center',
  },
  itemChoiceContainer: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'flex-end',
  },
  fontStyle: {
    fontSize: theme.myNormalFontSize,
  },
  selectBtn: {
    borderStyle: 'solid',
    borderWidth: 1,
    borderRadius: 4,
    paddingTop: 4,
    paddingBottom: 4,
    paddingLeft: 8,
    paddingRight: 8,
  },
});
